<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../Universal.css">
</head>
<body>
    <div id="cnblogs_post_body" class="blogpost-body">
        <h2><strong>java</strong><strong>语言概述</strong></h2>
    <p>Java<span style="font-family: 宋体">是</span><span style="font-family: Calibri">sun</span><span style="font-family: 宋体">公司开发的一门编程语言</span><span style="font-family: Calibri">,</span><span style="font-family: 宋体">目前被</span><span style="font-family: Calibri">Oracle</span><span style="font-family: 宋体">公司收购，编程语言就是用来编写软件的。</span></p>
    <h3>&nbsp;Java<span style="font-family: 宋体">的应用</span></h3>
    <ul>
    <li><span style="font-family: 宋体">开发</span>QQ<span style="font-family: 宋体">、迅雷程序</span><span style="font-family: Calibri">(</span><span style="font-family: 宋体">桌面应用软件</span><span style="font-family: Calibri">)</span></li>
    <li><span style="font-family: 宋体">淘宝、京东</span>(<span style="font-family: 宋体">互联网应用软件</span><span style="font-family: Calibri">)</span></li>
    <li><span style="font-family: Calibri">安卓应用程序</span></li>
    </ul>
    <h3>&nbsp;Java<span style="font-family: 宋体">的擅长</span></h3>
    <ul>
    <li><span style="font-family: 宋体">互联网：电商、</span>P2P<span style="font-family: 宋体">等等</span></li>
    <li><span style="font-family: 宋体">企业级应用：</span>ERP<span style="font-family: 宋体">、</span><span style="font-family: Calibri">CRM</span><span style="font-family: 宋体">、</span><span style="font-family: Calibri">BOS</span><span style="font-family: 宋体">、</span><span style="font-family: Calibri">OA</span><span style="font-family: 宋体">等等</span></li>
    </ul>
    <h3>Java<span style="font-family: 宋体">语言平台</span></h3>
    <ul>
    <li>JavaSE<span style="font-family: 宋体">（标准版）部分</span><span style="font-family: Calibri">,JavaSE</span><span style="font-family: 宋体">并不能开发大型项目。</span></li>
    <li>JavaEE<span style="font-family: 宋体">（企业版）部分</span><span style="font-family: Calibri">,</span><span style="font-family: 宋体">学习完</span><span style="font-family: Calibri">JavaEE</span><span style="font-family: 宋体">部分就可以开发各种大型项目了。</span></li>
    </ul>
    <h2><strong>java</strong><strong>语言开发环境</strong></h2>
    <p>JDK<span style="font-family: 宋体">是</span><span style="font-family: Helvetica">Java</span><span style="font-family: 宋体">开发环境，</span><span style="font-family: 宋体">官网</span> http://www.oracle.com/cn/index.html</p>
    <h3>JDK<span style="font-family: 宋体">的安装</span></h3>
    <p>傻瓜式安装，<span style="font-family: 宋体">双击安装程序，然后一路</span>next<span style="font-family: 宋体">即可</span><span style="font-family: Helvetica">，</span>安装的推荐方式：</p>
    <ul>
    <li>安装路径不要有中文或者特殊符号如空格等。</li>
    <li>所有和开发相关的软件最好安装目录统一。</li>
    <li><span style="font-family: 宋体">当提示安装</span>JRE<span style="font-family: 宋体">时，可以选择不安装。建议还是安装上。</span></li>
    </ul>
    <p>&nbsp;验证安装是否成功，<span style="font-family: 宋体">通过</span>DOS<span style="font-family: 宋体">命令，切换到</span><span style="font-family: Helvetica">JDK</span><span style="font-family: 宋体">安装的</span><span style="font-family: Helvetica">bin</span><span style="font-family: 宋体">目录下。比如&nbsp;<span class="cnblogs_code">D:\develop\Java\jdk1.<span style="color: rgba(128, 0, 128, 1)">7</span>.0_72\bin</span>，</span><span style="font-family: 宋体">然后分别输入</span>javac<span style="font-family: 宋体">和</span><span style="font-family: Helvetica">java</span><span style="font-family: 宋体">，如果正常显示一些内容，说明安装成功。</span></p>
    <h3><span style="font-family: 宋体">配置环境变量</span></h3>
    <p><span style="font-family: 宋体">环境变量的作用：由于</span>javac<span style="font-family: 宋体">和</span><span style="font-family: Calibri">java</span><span style="font-family: 宋体">命令只能在固定的目录下才能执行，而我们写的代码如果都和</span><span style="font-family: Calibri">javac</span><span style="font-family: 宋体">及</span><span style="font-family: Calibri">java</span><span style="font-family: 宋体">命令放在相同的目录中的话，会显得很乱”，为了让Java的bin目录下的javac命令可以在任意目录下执行，就得配置环境变量。</span></p>
    <p>具体安装参考：<a href="http://www.cnblogs.com/Belieflee/p/4778315.html" target="_blank">JAVA开发环境的搭建（配置JAVA开发环境）</a></p>
    <p><strong>JDK</strong><strong>和</strong><strong>JRE以及</strong><strong>跨平台</strong></p>
    <p>JDK<span style="font-family: 宋体">与</span><span style="font-family: Helvetica">JRE</span><span style="font-family: 宋体">的关系</span></p>
    <ul>
    <li>JDK：Java Development Kit ，Java语言的开发工具包，提供了Java语言的开发工具，它里面包含了JRE，同时也就包含了JVM（Java虚拟机）。</li>
    <li>JRE<span style="font-family: 宋体">：</span><span style="font-family: Helvetica">Java Runtime Environment，</span><span style="font-family: 宋体">它是</span><span style="font-family: Helvetica">Java</span><span style="font-family: 宋体">运行环境，如果你不需要开发只需要运行</span><span style="font-family: Helvetica">Java</span><span style="font-family: 宋体">程序，那么你可以安装</span><span style="font-family: Helvetica">JRE</span><span style="font-family: 宋体">。例如程序员开发出的程序最终卖给了用户，用户不用开发，只需要运行程序，所以用户在电脑上安装</span><span style="font-family: Helvetica">JRE</span><span style="font-family: 宋体">即可。它包含了Java虚拟机，也就是JVM，同时还包含了Java语言运行需要的核心类库。</span></li>
    </ul>
    <p>跨平台特性：<span style="font-family: 宋体">平台指的是操作系统</span> <span style="font-family: 宋体">（</span>Windows<span style="font-family: 宋体">，</span><span style="font-family: Helvetica">Linux</span><span style="font-family: 宋体">，</span><span style="font-family: Helvetica">Mac</span><span style="font-family: 宋体">）。只需在相应的平台上安装Java虚拟机，就可以运行</span>Java<span style="font-family: 宋体">程序</span><span style="font-family: Helvetica">。</span></p>
    <h2><span style="font-family: Helvetica">使用IntelliJ IDEA打印Hello World</span></h2>
    <h3><span style="font-family: Helvetica">第一步：创建新项目</span></h3>
    <p><span style="font-family: Helvetica"><img src="https://images2015.cnblogs.com/blog/612774/201707/612774-20170701211232211-2109811476.png" alt=""></span></p>
    <h3>第二步：选择jdk，然后next</h3>
    <p><img src="https://images2015.cnblogs.com/blog/612774/201707/612774-20170701211457883-150724723.png" alt=""></p>
    <h3>第三步：选择Hello World模板，然后Next</h3>
    <p>&nbsp;<img src="https://images2015.cnblogs.com/blog/612774/201707/612774-20170701211626743-101552981.png" alt=""></p>
    <h3>第四步：输入项目名称，然后Finish</h3>
    <p><img src="https://images2015.cnblogs.com/blog/612774/201707/612774-20170701211759305-689114650.png" alt=""></p>
    <h3>第五步：运行</h3>
    <p><img src="https://images2015.cnblogs.com/blog/612774/201707/612774-20170701211901883-623625448.png" alt=""></p>
    <h3>第六步：查看结果</h3>
    <p><img src="https://images2015.cnblogs.com/blog/612774/201707/612774-20170701211940899-68699482.png" alt=""></p>
    <h2><span style="line-height: 1.5">Java</span><span style="font-family: 宋体">代码的编写执行过程</span></h2>
    <p><span style="font-family: 宋体">源文件：编写</span><span style="font-family: Helvetica">Java</span><span style="font-family: 宋体">源文件（我们也称之为源代码文件），它的扩展名为</span><span style="font-family: Helvetica">.java</span><span style="font-family: 宋体">；</span></p>
    <p><span style="font-family: 宋体">编译：然后通过编译器把源文件编译成字节码文件，字节码文件扩展名为</span><span style="font-family: Helvetica">.class</span><span style="font-family: 宋体">；</span></p>
    <p><span style="font-family: 宋体">运行：最后使用解释器来运行字节码文件。</span></p>
    <h2><span style="font-family: 宋体">CentOS7下Java8安装</span></h2>
    <p><span style="font-family: 宋体">1、到<a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html</a>找到<a id="jdk-8u221-oth-JPRXXXjdk-8u221-linux-x64.tar.gz" class="download" name="jdk-8u221-oth-JPRXXXjdk-8u221-linux-x64.tar.gz"></a>jdk-8u221-linux-x64.tar.gz的下载地址，需要登录。</span></p>
    <p><span style="font-family: 宋体">2、打开终端，使用 wget命令下载。比如：</span>wget <a href="https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/jdk-8u221-linux-x64.tar.gz?AuthParam=1569641530_05c699a00ac2afe0c0dde7cc5784e4d5">https://download.oracle.com/otn/java/jdk/8u221-b11/230deb18db3e4014bb8e3e8324f81b43/jdk-8u221-linux-x64.tar.gz?AuthParam=1569641530_05c699a00ac2afe0c0dde7cc5784e4d5</a></p>
    <p>3、解压，tar -xzvf&nbsp;jdk-8u221-linux-x64.tar.gz?AuthParam=1569641530_05c699a00ac2afe0c0dde7cc5784e4d5</p>
    <p><span style="font-family: 宋体">4、移动到/usr/local目录下，mv jdk-8u221-linux-x64.tar.gz?AuthParam=1569641530_05c699a00ac2afe0c0dde7cc5784e4d5 /opt/usr</span></p>
    <p><span style="font-family: 宋体">5、切换到opt目录下，cd /opt/usr</span></p>
    <p><span style="font-family: 宋体">6、改名为java8，mv jdk-8u221-linux-x64.tar.gz?AuthParam=1569641530_05c699a00ac2afe0c0dde7cc5784e4d5 java8</span></p>
    <p><span style="font-family: 宋体">7、配置环境变量，vi /etc/profile,在文件后面追加以下代码：</span></p>
    <p>JAVA_HOME=/usr/local/java8<br>JRE_HOME=/usr/local/java8/jre<br>PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin<br>CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib<br>export JAVA_HOME JRE_HOME PATH CLASSPATH</p>
    <p>8、执行source /etc/profile命令使配置生效，到这一步就算安装完成了，使用java -version查看安装是否成功。</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>参考文档：<a href="https://www.cnblogs.com/yjlch1016/p/8900841.html">https://www.cnblogs.com/yjlch1016/p/8900841.html</a></p>
    </div>
</body>
</html>